layui.define(["table", "form", "admin"], function (exports) {
    var $ = layui.$,
        table = layui.table,
        form = layui.form;

    table.render({
        elem: '#LAY-live-status-manage'
        , url: '/admin/live/live_status'
        , cols: [[
            { field: 'id', title: 'ID', width: 100, fixed: "left" }
            , { field: 'anchorid', title: '主播ID', width: 100, fixed: "left" }
            , {
                field: '', title: '主播昵称', width: 120, templet: function (d) {
                    return d.anchor ? d.anchor.nick_name : '';
                }
            },
            , { field: 'start_time', title: '开播时间', width: 161 }
            , { field: 'title', title: '直播标题', width: 150 },
            {
                field: '', title: '直播状态', width: 120, templet: function (d) {
                    if (d.stream_status == 1) {
                        return '<font color=green>正常</font>';
                    } else {
                        return '<font color=red>异常</font>';
                    }
                }
            },
        ]]
        , page: true
        , limit: 20
        , height: 'full-140'
        , text: '对不起，加载出现异常！'
        , even: true
    });

    table.on("tool(LAY-live-status-manage)", function (obj) {
        if (obj.event === "user_duration") {
            layer.open({
                type: 2,
                title: "用户在线时长",
                content: "/admin/live/user_duration?liveid=" + obj.data.liveid,
                maxmin: true,
                area: ["1200px", "600px"],
            });
        }
    });


    exports("live_status", {});
});
